import json
import unittest
from middleWare import Middleware
from dao.Result import Result
from dao.Result_feature import Result as res
from intelligence.face import FaceRecognition
from config.Instrument import Instrument_toml
from dao.Result_leave_history import Result as Res




mid = Middleware()

temp = res(**mid.get_config())
temp.start()
user = temp.query()
temp.close()
user_c = []

for i in user:
    if i[-2] == "2":
        user_c.append([i[1],i[-1]])
print(user_c)
# # data = mid.get_config()
# # res = res(**data)
# # face = FaceRecognition(target_name_count=2, timeout_seconds=20)
# # face.add_face(res)
# # ans = face.run()
# # tom = Instrument_toml()
# # id = mid.data_binding_user_by_id(tom.GetStrogeToml('nickname'))['user_id']
# # print(id)
# # res = Res(**mid.get_config())
# # res.start()
# # res.insert()
# # res.close()
# ans = mid.data_bind_his()
# print(ans)

# ans = mid.contian('957')
# ans = mid.data_binding_user_by_id('south')
# ans = mid.data_binding_user_leave()
# print(ans)

# r = Result()
# r.start()
# ans = r.query_by_id('957')
# r.close()
# print(ans)


# class TestDataBindingUser(unittest.TestCase):
#     def test_data_binding_user(self):
#         # Create an instance of the class
#         obj = Middleware()
        
#         # Call the method to test
#         result = obj.data_binding_user()
        
#         # Assert the expected result
#         self.assertEqual(result, None)
        


# # Run the tests
# if __name__ == '__main__':
    # unittest.main()

# class TestInstrumentToml(unittest.TestCase):

#     def test_get_stroge_toml(self):
#         test = Instrument_toml()
#         text = test.GetStrogeToml('nickname')
#         self.assertEqual(text, 'your_expected_result')


# class TestDataBindingUserById(unittest.TestCase):
#     def test_data_binding_user_by_id(self):
#         # Create an instance of the class being tested
#         obj = Middleware()

#         # Call the function being tested
#         ans = obj.data_binding_user_by_id('957')

#         #使用单元测试输出结果，不要用equal
#         self.assertEqual(ans, None)
        

# if __name__ == '__main__':
#     unittest.main()


# import unittest

# class TestContain(unittest.TestCase):
    
#     def test_contain_existing_nickname(self):
#         # Arrange
#         nickname = "957"
#         expected = False
        
#         # Act
#         result = mid.contian(nickname)
        
#         # Assert
#         self.assertEqual(result, expected)
    
#     def test_contain_non_existing_nickname(self):
#         # Arrange
#         nickname = "95"
#         expected = True
        
#         # Act
#         result = mid.contian(nickname)
        
#         # Assert
#         self.assertEqual(result, expected)

# if __name__ == '__main__':
#     unittest.main()

# import unittest

# class TestGetConfig(unittest.TestCase):
#     def test_get_config(self):
#         # Create an instance of the class
#         obj = Middleware()
        
#         # Call the function to test
#         result = obj.get_config()
        
#         # Assert the expected result
#         expected_result = {
#             "url": "expected_url",
#             "user": "expected_user",
#             "password": "expected_password",
#             "db": "expected_database"
#         }
#         self.assertEqual(result, expected_result)

# if __name__ == '__main__':
#     unittest.main()

